﻿@{
    ViewBag.PageTitle = Resources.Intercamber.LeftBar_MyDiscussions;
}
@section PageHead
{
    <script type="text/javascript">
        $(function () {
            $(".jqbutton").button();
            $("#leftButtonDiscussions").addClass("ui-menu-sel");
            $("#gridDiscussions").jqGrid({
                //autowidth: true,
                datatype: 'json',
                width: '100%',
                height: '100%',
                jsonReader: { 'repeatitems': false, 'id': 'IdUser' },
                loadonce: true,
                url: '/Talk/MyDiscussionsData',
                viewrecords: true,
                colModel: [
                    { name: 'IdUser', fixed: true, formatter: gridColumnTalk, label: '@Resources.Intercamber.Talk', resizable: false, sortable: false, width: 45, index: 'IdUser', align: 'center' },
                    { name: "NameUser", width: 90, align: 'center', label: '@Resources.Intercamber.SearchContacts_ColName', formatter: gridColumnName },
                    {
                        name: 'Connected', fixed: true, formatter: gridColumnConnected, align: 'center',
                        label: '@Resources.Intercamber.SearchContacts_ColConnected', width: 90, index: 'Connected'
                    },
                    { name: "StrDateStart", width: 90, align: 'center', label: '@Resources.Intercamber.MyDiscussions_Started' },
                    { name: "StrDateLastMessageSent", width: 90, align: 'center', label: '@Resources.Intercamber.MyDiscussions_LastMessageSent' },
                    { name: "StrDateLastMessageReceived", width: 90, align: 'center', label: '@Resources.Intercamber.MyDiscussions_LastMessageReceived' },
                    { name: "NumberMessagesReceived", width: 90, align: 'center', label: '@Resources.Intercamber.MyDiscussions_NumberMessagesReceived' },
                    { name: "NumberMessagesSent", width: 90, align: 'center', label: '@Resources.Intercamber.MyDiscussions_NumberMessagesSent' },
                ],
                subGrid: false,
                subGridOptions: { expandOnLoad: true, selectOnExpand: false, reloadOnExpand: false },
                loadComplete: function () {
                    $("#gridDiscussions").jqGrid("hideCol", "subgrid");
                    $("#gridDiscussions").jqGrid('setGridWidth', 800, true);
                },
            }).trigger("reloadGrid", [{ page: 1 }]);
        });

        // grid formatters 
        function gridColumnTalk(cellvalue) {
            return "<img id=\"add" + cellvalue + "\" title=\"\" class='imgButton' src='/Images/Mail.png' onclick=\"window.location='../Talk/Discussion/" + cellvalue + "'\" />";
        }
        function gridColumnConnected(cellvalue, options, rowobject) {
            var connected = rowobject.Connected;
            return "<img src='/Images/" + (connected ? "Online.png" : "Offline.png") + "' title='" + (connected ? "@(Resources.Intercamber.Connected)" : "@(Resources.Intercamber.Disconnected)") + "'  />";
        }
        function gridColumnName(cellvalue, options, rowobject) {
            var label = rowobject.NameUser, id = rowobject.IdUser;
            if (typeof profilViewerManager.showProfil !== "undefined")
                return "<label onclick='profilViewerManager.showProfil(" + id + ");' class='link'>" + label + "<label>";
            return label;
        }

    </script>
    @Html.Partial("~/Views/Shared/_ProfilViewerPartial.cshtml")
}

@section PageLeftBar {
    @Html.Partial("~/Views/Shared/_LeftBarUserDetailPartial.cshtml")
}

@section PageContent {
    <div class="innerTitle ui-corner-all">
        @Resources.Intercamber.LeftBar_MyDiscussions
    </div>
    <br />
    <br />
    <table id='gridDiscussions' style="width: 100%"></table>
}
